package com.scfire.baseInfo

import java.util.HashMap;

/** 
 * Copyright 2015 Shudao Info Tech Co. Ltd.  All rights reserved.
 * @author lhzeng
 * @email zenglh@haoshudao.com
 * @date 2015年6月7日 下午2:34:36 
 * @version V1.0
 */

class MessageGson extends Gson {
	
	String otherInfoKey	
	
	def MessageGson(int type, String text){
		super()
		if(type < ConstValue.otherInfokey.length){
			this.otherInfoKey = ConstValue.otherInfokey[type]
		}else{
			this.otherInfoKey = "otherInfoKey"
		}
		
		def otherInfoValue = new HashMap()
		if(text){
			super.setInfo(["type":type,"text":text])
		}else{
			super.setInfo(["type":type])
		}
		super.getInfo().put(this.otherInfoKey,otherInfoValue)
	}
	
	def MessageGson(int type, String otherInfoKey, HashMap otherInfo){
		super()
		this.otherInfoKey = otherInfoKey
		this.setInfo(["type":type,otherInfoKey:otherInfo])
	}
	
	def setType(int type){
		super.getInfo().put("type", type)
	}
	
	def recordOtherInfo(String key, Object value){
		def infoValue = super.getInfo()
		def otherInfoValue = infoValue.get(this.otherInfoKey)
		otherInfoValue.put(key, value)
	}
	
	def findOtherInfo(){
		def infoValue = super.getInfo()
		def otherInfoValue = infoValue.get(this.otherInfoKey)
		return otherInfoValue
	}
	
	def findText(){
		def infoValue = super.getInfo()
		return infoValue.get("text")
	}
	
	def recordText(String text){
		def infoValue = super.getInfo()
		infoValue.put("text", text)
	}
	
	def findType(){
		def infoValue = super.getInfo()
		return infoValue.get("type")
	}

	public String getOtherInfoKey() {
		return otherInfoKey;
	}

	public void setOtherInfoKey(String otherInfoKey) {
		this.otherInfoKey = otherInfoKey;
	}
	
}
 